﻿<UserControl x:Class="MARC.EHRS.VisualizationClient.Silverlight.Visualizer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="600" d:DesignWidth="800"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:control="clr-namespace:MARC.EHRS.Silverlight;assembly=MARC.EHRS.Silverlight" Unloaded="UserControl_Unloaded">
    <UserControl.Resources>
        <Storyboard x:Name="sbShowHelp" Storyboard.TargetName="AboutGrid">
            <DoubleAnimation Storyboard.TargetProperty="(content:PopperMenu.RenderTransform).(TranslateTransform.Y)" To="0" Duration="0:0:00.5"/>
        </Storyboard>
        <Storyboard x:Name="sbHideHelp" Storyboard.TargetName="AboutGrid">
            <DoubleAnimation Storyboard.TargetProperty="(content:PopperMenu.RenderTransform).(TranslateTransform.Y)" To="1500" Duration="0:0:00.5"/>
        </Storyboard>
        <Storyboard x:Name="sbShowCaptureMenu" Storyboard.TargetName="CaptureMenu">
            <DoubleAnimation Storyboard.TargetProperty="(content:PopperMenu.RenderTransform).(TranslateTransform.Y)" To="0" Duration="0:0:00.25"/>
        </Storyboard>
        <Storyboard x:Name="sbMouseHideCaptureMenu" Storyboard.TargetName="CaptureMenu">
            <DoubleAnimation Storyboard.TargetProperty="(content:PopperMenu.RenderTransform).(TranslateTransform.Y)" To="45" Duration="0:0:00.25"/>
        </Storyboard>
        <Storyboard x:Name="sbHideCaptureMenu" Storyboard.TargetName="CaptureMenu">
            <DoubleAnimation Storyboard.TargetProperty="(content:PopperMenu.RenderTransform).(TranslateTransform.Y)" To="80" Duration="0:0:00.25"/>
        </Storyboard>
        <Storyboard x:Name="sbShowPlaybackMenu" >
            <DoubleAnimation Storyboard.TargetName="PlaybackMenu" Storyboard.TargetProperty="(content:PopperMenu.RenderTransform).(TranslateTransform.Y)" To="0" Duration="0:0:00.25"/>
            <DoubleAnimation Storyboard.TargetName="PlaybackNavigator" Storyboard.TargetProperty="(Border.RenderTransform).(TranslateTransform.Y)" To="0" Duration="0:0:00.25"/>
        </Storyboard>
        <Storyboard x:Name="sbHidePlaybackMenu">
            <DoubleAnimation  Storyboard.TargetName="PlaybackMenu" Storyboard.TargetProperty="(content:PopperMenu.RenderTransform).(TranslateTransform.Y)" To="80" Duration="0:0:00.25"/>
            <DoubleAnimation Storyboard.TargetName="PlaybackNavigator" Storyboard.TargetProperty="(Border.RenderTransform).(TranslateTransform.Y)" To="100" Duration="0:0:00.25"/>
        </Storyboard>
        <Storyboard x:Name="sbShowSelector" Storyboard.TargetName="selector">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.RenderTransform).(CompositeTransform.TranslateY)">
                <SplineDoubleKeyFrame KeyTime="0:00:0.5" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="sbHideSelector" Storyboard.TargetName="selector">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.RenderTransform).(CompositeTransform.TranslateY)">
                <SplineDoubleKeyFrame KeyTime="0:00:00.5" Value="1500"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <Style TargetType="Slider">
                <Setter Property="BorderBrush" Value="Transparent"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Slider">
                            <Grid x:Name="Root">
                                <Grid.Resources>
                                    <ControlTemplate x:Key="RepeatButtonTemplate">
                                        <Grid x:Name="Root" Opacity="0" Background="Transparent"/>
                                    </ControlTemplate>
                                </Grid.Resources>
                                <Grid x:Name="HorizontalTemplate" Background="{TemplateBinding Background}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <!-- Track Layer -->
                                    <Rectangle x:Name="TrackRectangle" StrokeThickness="0" Fill="#000000" Grid.Column="0" Grid.ColumnSpan="3" Height="1" RadiusX="1" RadiusY="1" Margin="5,0,5,0" />
                                    <Rectangle x:Name="HorizontalTrackRectangleDisabledOverlay" Visibility="Collapsed"  Fill="White" Opacity=".55" Grid.Column="0" Grid.ColumnSpan="3" Height="3" RadiusX="1" RadiusY="1" Margin="5,0,5,0" />
                                    <!-- Repeat Buttons + Thumb -->
                                    <RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Height="18" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Column="0"/>
                                    <Thumb Height="18" x:Name="HorizontalThumb" Width="11" Grid.Column="1" IsTabStop="True"/>
                                    <!--<Rectangle x:Name="ThumbDisabledOverlay" RadiusX="2" RadiusY="2"  Width="11" Grid.Column="1" Fill="White" Opacity=".55" Visibility="Collapsed"/>-->
                                    <RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Height="18" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Column="2"/>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="Thumb">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Thumb">
                            <Grid>
                                <Grid.Background>
                                    <SolidColorBrush Color="Transparent"/>
                                </Grid.Background>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal"/>
                                        <VisualState x:Name="MouseOver"/>
                                        <VisualState x:Name="Pressed"/>
                                        <VisualState x:Name="Disabled"/>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="FocusStates">
                                        <VisualState x:Name="Focused">
                                        </VisualState>
                                        <VisualState x:Name="Unfocused"/>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                    <Grid Margin="1" Background="Transparent">
                                        <Ellipse x:Name="BackgroundGradient" >
                                            <Ellipse.Fill>
                                                <RadialGradientBrush Center="0.5,0.4">
                                                    <GradientStop Color="#ffffffff" Offset="0" />
                                                    <GradientStop Color="#88333333" Offset="1" />
                                            </RadialGradientBrush>
                                            </Ellipse.Fill>
                                        </Ellipse>
                                    </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <Grid Name="visualizerContent">
        </Grid>
            <control:PopperMenu Name="CaptureMenu" VerticalAlignment="Bottom" HorizontalAlignment="Center" MenuItemClicked="PopperMenu_MenuItemClicked" MouseEnter="CaptureMenu_MouseEnter" MouseLeave="CaptureMenu_MouseLeave">
            <control:PopperMenu.RenderTransform>
                <TranslateTransform Y="45"/>
            </control:PopperMenu.RenderTransform>
                <control:PopperMenu.MenuPanel>
                <StackPanel Orientation="Horizontal">
                    <RepeatButton Name="btnDiagram" ToolTipService.ToolTip="Change diagram" ToolTipService.Placement="Top">
                    <Image Source="diagram.png" Stretch="Fill"/>
                </RepeatButton>
                <RepeatButton Name="btnServer" ToolTipService.ToolTip="Change infrastructure" ToolTipService.Placement="Top">
                        <Image Source="server.png" Stretch="Fill"/>
                </RepeatButton>
                <ToggleButton Name="btnRecord" ToolTipService.ToolTip="Capture traffic" ToolTipService.Placement="Top">
                        <Image Source="rec.png" Stretch="Fill"/>
                    </ToggleButton>
                    <!--<ToggleButton Name="btnRandom" ToolTipService.ToolTip="Enable random" ToolTipService.Placement="Top">
                        <Image Source="random.png" Stretch="Fill"/>
                    </ToggleButton>-->

                    <RepeatButton Name="btnHelp" ToolTipService.ToolTip="About the Visualizer" ToolTipService.Placement="Top">
                        <Image Source="help.png" Stretch="Fill"/>
                </RepeatButton>
                    <RepeatButton Name="btnPlaybackMode" ToolTipService.ToolTip="Switch to playback mode" ToolTipService.Placement="Top">
                        <Image Source="switch_play.png" Stretch="Fill"/>
                    </RepeatButton>
                </StackPanel>
                </control:PopperMenu.MenuPanel>
            </control:PopperMenu>
        <control:PopperMenu Name="PlaybackMenu" VerticalAlignment="Bottom" HorizontalAlignment="Center" MenuItemClicked="PopperMenu_MenuItemClicked">
            <control:PopperMenu.RenderTransform>
                <TranslateTransform Y="80"/>
            </control:PopperMenu.RenderTransform>
            <control:PopperMenu.MenuPanel>
                <StackPanel Orientation="Horizontal">
                    <RepeatButton Name="btnOpen" ToolTipService.ToolTip="Open saved capture" ToolTipService.Placement="Top">
                        <Image Source="open.png" Stretch="Fill"/>
                    </RepeatButton>
                    <RepeatButton Name="btnSave" Visibility="Collapsed" ToolTipService.ToolTip="Save current capture" ToolTipService.Placement="Top">
                        <Image Source="save.png" Stretch="Fill"/>
                    </RepeatButton>
                    <ToggleButton Name="btnReplay" Visibility="Collapsed" ToolTipService.ToolTip="Play capture" ToolTipService.Placement="Top">
                        <Image Source="play.png" Stretch="Fill"/>
                    </ToggleButton>
                    <ToggleButton Name="btnSpeed" Visibility="Collapsed" ToolTipService.ToolTip="Slo-mo" ToolTipService.Placement="Top">
                        <Image Source="clock.png" Stretch="Fill"/>
                    </ToggleButton>
                    <RepeatButton Name="btnCaptureMode" ToolTipService.ToolTip="Switch to live mode" ToolTipService.Placement="Top">
                        <Image Source="switch_cap.png" Stretch="Fill"/>
                    </RepeatButton>
                </StackPanel>
            </control:PopperMenu.MenuPanel>
        </control:PopperMenu>
        <Border CornerRadius="6" BorderBrush="Black" Margin="0,0,0,64" BorderThickness="1" VerticalAlignment="Bottom" Width="250" Height="18" Name="PlaybackNavigator">
            <Border.RenderTransform>
                <TranslateTransform Y="100"/>
            </Border.RenderTransform>
            <Border.Background>
                <SolidColorBrush Color="#44000000"/>
            </Border.Background>
            <StackPanel Orientation="Horizontal">
                <sdk:Label Content="Paused" Foreground="White" Margin="2,0" Name="state"/>
                <Slider Width="140" Minimum="1" Maximum="5" Value="0" Name="timeline" ValueChanged="timeline_ValueChanged">
                </Slider>
                <sdk:Label Content="00:00:00" Name="position" Foreground="White" Margin="2,0"/>
            </StackPanel>
        </Border>
        <control:Selector Grid.Row="1" Grid.ColumnSpan="3" x:Name="selector" SelectionChanged="lstSelection_SelectionChanged" >
            <control:Selector.RenderTransform>
                <CompositeTransform TranslateX="0" TranslateY="1500"/>
            </control:Selector.RenderTransform>
        </control:Selector>
        <control:StatusBox x:Name="connectionStatus" AllowApprove="False" AllowCancel="False" Content="Content" Visibility="Collapsed" OnAccept="connectionStatus_OnAccept" />
        <control:StatusBox x:Name="eraseCaptureStatus" AllowApprove="True" AllowCancel="True" Content="There is a visualization in memory that will be closed if you proceed." OnAccept="eraseCaptureStatus_OnAccept" Visibility="Collapsed"/>
        <control:StatusBox x:Name="generalErrorAlert" AllowApprove="True" Content="An error occurred." Visibility="Collapsed"/>
        <Grid Name="AboutGrid">
            <Grid.RenderTransform>
                <TranslateTransform Y="1500"/>
            </Grid.RenderTransform>
            <Grid.Background>
                <RadialGradientBrush>
                    <GradientStop Offset="1" Color="#EE000000"/>
                    <GradientStop Offset="0" Color="#CC000000"/>
                </RadialGradientBrush>
            </Grid.Background>
            <Border VerticalAlignment="Center" CornerRadius="12" HorizontalAlignment="Center" Width="640" Height="480">
                <Border.Background>
                    <LinearGradientBrush>
                        <GradientStop Offset="0" Color="White"/>
                        <GradientStop Offset="1" Color="AliceBlue"/>
                    </LinearGradientBrush>
                </Border.Background>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="24"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="32"/>
                    </Grid.RowDefinitions>
                    <Border Grid.Row="0" CornerRadius="12,0,12,0">
                        <Border.Background>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                <GradientStop Offset="0" Color="#88ff9933"/>
                                <GradientStop Offset="1" Color="#22ff9933"/>
                            </LinearGradientBrush>
                        </Border.Background>
                        <sdk:Label Content="About the MARC-HI Visualizer" FontSize="14" FontWeight="Bold" Margin="2"/>
                    </Border>
                    <RichTextBox Grid.Row="1" IsReadOnly="true"  VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" Name="aboutText">
                    </RichTextBox>
                    <RepeatButton Click="RepeatButton_Click" Grid.Row="2" Margin="0,0,15,5" Padding="5,3" VerticalAlignment="Bottom" HorizontalAlignment="Right">Close</RepeatButton>
                </Grid>
            </Border>
        </Grid>

    </Grid>
    
</UserControl>
